package com.aididi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
@RefreshScope
public class NacosConsumerApplication {

	public static void main(String[] args) {
		SpringApplication.run(NacosConsumerApplication.class, args);
	}

	/**
	 *  使用springcloud的LoadBalanced负载均衡器
	 *  默认轮训
	 * @return
	 */
	@Bean
	@LoadBalanced	  //添加此注解后，使用RestTemplate调用时只能调用服务名，不能用host：port的方式，否则报错
	public RestTemplate restTemplate(){
		return new RestTemplate();
	}

}
